<?php
/**
 * Created by PhpStorm.
 * User: wuanjie
 * Date: 16-6-8
 * Time: 下午3:08
 */
class AppointmentModel extends \Core_CMode {

    public $_table = '`yaf_appointment`';
    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'id' => '预约id',
            'service_id' => '业务id',
            'service_type' => '业务类型',
            'client_type' => '客户类型',
            'client_name' => '联系人姓名',
            'client_phone' => '联系人电话',
            'appointment_date' => '预约时间',
            'appointment_address' => '预约地址',
            'appointment_detail' => '详细信息',
        );
    }

    /**
     * 楠岃瘉瑙勫垯
     *
     */
    public function rules() {
        return array(
            'default'=> array(
                array('client_name', 'required|maxlength[20]'),
                array('client_phone', 'required|maxlength[20]'),
                array('appointment_date', 'maxlength[20]'),
                array('appointment_address', 'maxlength[50]'),
                array('appointment_detail', 'maxlength[250]'),
            ),
        );
    }

    /**
     * 鎵归噺鍒犻櫎
     *
     */
    public function delAppointments($ids) {
        $ids_str = implode(',', $ids);
        $where = 'appointment_id IN ('.$ids_str.')';
        return $this->delete($where);
    }
}